﻿
using System;
using System.Collections;

namespace Xacml.Core.Policy
{
  public class TargetMatchCollection : TargetMatchCollectionReadWrite
  {
    public override TargetMatchBaseReadWrite this[int i]
    {
      get
      {
        return (TargetMatchBaseReadWrite) this.List[i];
      }
      set
      {
        throw new NotSupportedException();
      }
    }

    public TargetMatchCollection(TargetMatchCollectionReadWrite items)
    {
      foreach (TargetMatchBaseReadWrite matchBaseReadWrite in (CollectionBase) items)
      {
        if (matchBaseReadWrite is SubjectMatchElementReadWrite)
          this.List.Add((object) new SubjectMatchElement(matchBaseReadWrite.MatchId, matchBaseReadWrite.AttributeValue, matchBaseReadWrite.AttributeReference, matchBaseReadWrite.SchemaVersion));
        else if (matchBaseReadWrite is ActionMatchElementReadWrite)
          this.List.Add((object) new ActionMatchElement(matchBaseReadWrite.MatchId, matchBaseReadWrite.AttributeValue, matchBaseReadWrite.AttributeReference, matchBaseReadWrite.SchemaVersion));
        else if (matchBaseReadWrite is ResourceMatchElementReadWrite)
          this.List.Add((object) new ResourceMatchElement(matchBaseReadWrite.MatchId, matchBaseReadWrite.AttributeValue, matchBaseReadWrite.AttributeReference, matchBaseReadWrite.SchemaVersion));
        else if (matchBaseReadWrite is EnvironmentMatchElementReadWrite)
          this.List.Add((object) new EnvironmentMatchElement(matchBaseReadWrite.MatchId, matchBaseReadWrite.AttributeValue, matchBaseReadWrite.AttributeReference, matchBaseReadWrite.SchemaVersion));
      }
    }

    public TargetMatchCollection()
    {
    }

    public override void Clear()
    {
      throw new NotSupportedException();
    }

    public override int Add(TargetMatchBaseReadWrite value)
    {
      return this.List.Add((object) (TargetMatchBase) value);
    }

    public override void RemoveAt(int index)
    {
      throw new NotSupportedException();
    }
  }
}
